const formatTime = date => {
    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()

    return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
    n = n.toString()
    return n[1] ? n : '0' + n
}

var filter = {
    color: function (price) {
        switch (price) {
            case 1:
                return '#B6B6B6'
                break;
            case 2:
                return '#BCBCFF'
                break;
            case 3:
                return '#4242FF'
                break;
            case 4:
                return '#FF00FF'
                break;
            case 5:
                return '#FF8900'
                break;
            default:
                return '#000000'
        }
    },
    text: function (price) {
        switch (price) {
            case 1:
                return '基础'
                break;
            case 2:
                return '普通'
                break;
            case 3:
                return '稀有'
                break;
            case 4:
                return '史诗'
                break;
            case 5:
                return '传说'
                break;
            default:
                return '其他'
        }
    }
}

module.exports = {
    formatTime: formatTime,
    color: filter.color,
    text: filter.text
}
